//
//  ZYQTabBarController.m
//  bbwy
//
//  Created by 张亚祺 on 2018/3/26.
//  Copyright © 2018年 zhangyaqi. All rights reserved.
//

#import "ZYQTabBarController.h"
#import "ZYQHomeTableViewController.h"
#import "ZYQMotionTableViewController.h"
#import "ZYQHealthTableViewController.h"
#import "ZYQMallTableViewController.h"

@interface ZYQTabBarController ()

@end

@implementation ZYQTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // 添加子控制器(4个子控制器)
    [self setupAllChildViewController];
    
    // 设置tabBar上按钮内容
    [self setupAllTitleButton];
    
//    self.tabBar.tintColor = RGB(77, 223, 98);
}

#pragma mark - 添加所有的子控制器
- (void)setupAllChildViewController {
    // 1.首页
    ZYQHomeTableViewController *homeVc = [[ZYQHomeTableViewController alloc] init];
    UINavigationController *navHome = [[UINavigationController alloc] initWithRootViewController:homeVc];
    [self addChildViewController:navHome];
    
    // 2.运动
    ZYQMotionTableViewController *motionVc = [[ZYQMotionTableViewController alloc] init];
    UINavigationController *navMovement = [[UINavigationController alloc] initWithRootViewController:motionVc];
    [self addChildViewController:navMovement];
    
    // 3.健康
    ZYQHealthTableViewController *healthVc = [[ZYQHealthTableViewController alloc] init];
    UINavigationController *navHealth = [[UINavigationController alloc] initWithRootViewController:healthVc];
    [self addChildViewController:navHealth];
    
    // 4.商城
    ZYQMallTableViewController *mallVc = [[ZYQMallTableViewController alloc] init];
    UINavigationController *navMall = [[UINavigationController alloc] initWithRootViewController:mallVc];
    [self addChildViewController:navMall];
    
    // 5.会员
    UIViewController *meVc = [[UIViewController alloc] init];
    meVc.view.backgroundColor = [UIColor orangeColor];
    UINavigationController *navMe = [[UINavigationController alloc] initWithRootViewController:meVc];
    [self addChildViewController:navMe];
}

#pragma mark - 设置TabBar上按钮内容
- (void)setupAllTitleButton {
    // 1.首页
    UINavigationController *homeNav = self.childViewControllers[0];
    homeNav.tabBarItem.title = @"首页";
    homeNav.tabBarItem.image = [UIImage imageNamed:@"home"];
    homeNav.tabBarItem.selectedImage = [UIImage imageNamed:@"home_h"];
    
    // 2.运动
    UINavigationController *movementNav = self.childViewControllers[1];
    movementNav.tabBarItem.title = @"运动";
    movementNav.tabBarItem.image = [UIImage imageNamed:@"classify"];
    movementNav.tabBarItem.selectedImage = [UIImage imageNamed:@"classify_h"];
    
    // 3.健康
    UINavigationController *healthNav = self.childViewControllers[2];
    healthNav.tabBarItem.title = @"健康";
    healthNav.tabBarItem.image = [UIImage imageNamed:@"shopcar"];
    healthNav.tabBarItem.selectedImage = [UIImage imageNamed:@"shopcar_h"];
    
    // 4.商城
    UINavigationController *mallNav = self.childViewControllers[3];
    mallNav.tabBarItem.title = @"商城";
    mallNav.tabBarItem.image = [UIImage imageNamed:@"shopcar"];
    mallNav.tabBarItem.selectedImage = [UIImage imageNamed:@"shopcar_h"];
    
    // 5.会员
    UINavigationController *meNav = self.childViewControllers[4];
    meNav.tabBarItem.title = @"会员";
    meNav.tabBarItem.image = [UIImage imageNamed:@"me"];
    meNav.tabBarItem.selectedImage = [UIImage imageNamed:@"me_h"];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
